/**
 * 角色菜单
 */
/**
 * 角色管理编辑
 * @author peishifeng
 */
layui.config({
				base: 'js/',
				version: true //一般用于更新模块缓存，默认不开启。设为true即让浏览器不缓存。也可以设为一个固定的值，如：201610
				,debug: true //用于开启调试模式，默认false，如果设为true，则JS模块的节点会保留在页面
});
layui.use(['tree', 'form'], function() {
	var $ = layui.jquery,
		layerTips =layui.layer;
		layer = layui.layer, //获取当前窗口的layer对象
		form = layui.form;
		form.render();
		var id=getUrlParam("id");
		form.on("submit(edit)",function(data){
			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			
//			$.ajax({
//				url:"doUpdateRole",
//				data:data.field
//			}).success(function(result){
//				if(!result.success){
//					layer.msg(result.msg);
//					return false;
//				}
//				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
//				parent.layer.close(index); //再执行关闭  
//				layer.close(index);
//				//刷新表格数据
//				$(window.parent.document).find("button[data-type=refresh]").click();
//			}).fail(function(result){
//				if(!result.success){
//					layer.msg(result.msg);
//				}
//			});
			
			parent.layer.close(index); //再执行关闭  
			layer.close(index);
			$(window.parent.document).find("button[data-type=refresh]").click();
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
		
});
function getUrlParam(name){  
    //构造一个含有目标参数的正则表达式对象  
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");  
    //匹配目标参数  
    var r = window.location.search.substr(1).match(reg);  
    //返回参数值  
    if (r!=null) return unescape(r[2]);  
    return null;  
}

 // zTree = $.fn.zTree.init(tree, setting, [{"id":1,"pid":0,"title":"用户管理","checked":true},{"id":2,"pid":1,"title":"用户列表","checked":true},{"id":3,"pid":1,"title":"权限管理","checked":true},{"id":4,"pid":1,"title":"角色列表","checked":true},{"id":8,"pid":7,"title":"接口仓库","checked":true},{"id":5,"pid":0,"title":"数据库","checked":true},{"id":6,"pid":5,"title":"优化","checked":true},{"id":7,"pid":0,"title":"接口管理","checked":true},{"id":202,"pid":0,"title":"文件管理"},{"id":203,"pid":0,"title":"一级菜单","checked":true},{"id":209,"pid":203,"title":"二级","checked":true},{"id":210,"pid":209,"title":"三级菜单","checked":true},{"id":216,"pid":5,"title":"dasdas","checked":true}]);